﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml.Serialization;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Drawing.Design;

namespace ESLReminder
{
    public abstract class ReminderModule : IPlugin
    {
        private bool m_Enabled = true;
        [DefaultValueAttribute(true)]
        [Browsable(false)]
        public bool Enabled
        {
            get { return m_Enabled; }
            set {
                m_Enabled = value;
                if (ConfigPanel != null)
                    ConfigPanel.Enabled = value;
            }
        }
        protected IReminderInterface m_Reminder;
        private PluginInfo m_PluginInfo;
        protected ReminderModule(PluginInfo info, string description)
        {
            m_PluginInfo = info;
            m_Description = description;
        }
        public virtual Control ConfigPanel
        {
            get
            {
                return null;
            }
        }
        [Browsable(false)]
        public PluginInfo PluginInformation
        {
            get
            {
                return m_PluginInfo;
            }
        }
        [Browsable(false)]
        public string Description
        {
            get { return m_Description; }
        }

        private string m_Description;
        
        private static List<ReminderModule> m_Modules = new List<ReminderModule>();
        public void PluginInit(IPluginHost host)
        {
            m_Reminder = host as IReminderInterface;
            PluginLoadedEx(m_Reminder);
        }
        public virtual void PluginLoadedEx(IReminderInterface host)
        {
            
        }
        private void Log(string type, string text)
        {
            Trace.WriteLine(String.Format("{0} ({1}): {2}", m_PluginInfo.PluginName,type, text));
        }
        protected void LogInfo(string text)
        {
            Log("INFO", text);
        }
        protected void LogError(string text)
        {
            Log("ERROR", text);
        }
        protected void LogWarning(string text)
        {
            Log("WARNING", text);
        }

        public virtual void ForeignPluginLoaded(IPlugin plugin){}
    }
}